package com.iccct.elastic.controller;

import com.iccct.elastic.model.Order;
import com.iccct.elastic.service.OrderService;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author iccct
 * @date 2021/11/15 16:57
 */
@RestController
public class IndexController {

    @Resource
    private OrderService orderService;

    @PostMapping("/saveBatch")
    public String saveBatch(@RequestBody List<Order> orderList){

        if (CollectionUtils.isEmpty(orderList)){
            return "文档不能为空";
        }
        orderService.saveAll(orderList);
        return "保存成功";
    }

    @GetMapping("/findOrder")
    public String findOrder(@RequestParam("id") Integer id){
        Order byId = orderService.findById(id);
        return "查询成功：" + byId;
    }
}
